package api

import (
	"github.com/gin-gonic/gin"
	"poem-server/middleware"
	"poem-server/mvc/controller"
	"poem-server/mvc/service"
)

func AddUserRouter(router *gin.Engine) {

	app := router.Group("/user")
	{
		controller := controller.NewUserController()
		app.POST("/login/username", controller.LoginByUserName)
		app.POST("/login/phone", controller.LoginByPhone)
		app.POST("/register/username", controller.RegisterByUserName)
		app.POST("/register/phone", controller.RegisterByPhone)
	}

	// 需要jwt 鉴权的路由
	auth := router.Group("/user").Use(middleware.JWTAuth(service.AppGuardName))
	{
		controller := controller.NewUserController()
		auth.GET("/info", controller.GetInfo)
		auth.POST("/update", controller.UpdateInfo)
		auth.GET("/logout", controller.Logout)
	}
}
